﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace WPFUnitTesting
{
    public class CustomerViewModel : INotifyPropertyChanged
    {
        private DateTime? dob;
        public event PropertyChangedEventHandler PropertyChanged;

        public ObservableCollection<Customer> Customers { get; set; }

        public string CustomerName {get; set; }

        public string DateOfBirth
        {
            get { return dob.HasValue?dob.Value.ToShortDateString():""; }
            set { dob = DateTime.Parse(value); }
        }

        public SaveCustomerCommand AddCustomer { get; set; }

        public CustomerViewModel()
        {
            Customers = new ObservableCollection<Customer>();
            AddCustomer = new SaveCustomerCommand();
            CommandManager.RegisterClassCommandBinding(this.GetType(),new CommandBinding(AddCustomer));
            
        }
      
    }
}
